package com.study.shop.controller.product;


import com.study.shop.entity.dto.TrademarkDTO;
import com.study.shop.entity.po.Trademark;
import com.study.shop.entity.common.MyPage;
import com.study.shop.entity.common.R;
import com.study.shop.service.TrademarkService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/product/baseTrademark")
@RequiredArgsConstructor
public class TrademarkController {
    private final TrademarkService trademarkService;

    // 分页查询 trademark
    @GetMapping("/{page}/{limit}")
    public R<MyPage<Trademark>> page(@PathVariable("page") Integer page,
                                     @PathVariable("limit") Integer limit) {
        MyPage<Trademark> pages = trademarkService.page(page, limit);
        return R.success(pages);
    }

    // 保存trademark
    @PostMapping("/save")
    public R<Object> save(@RequestBody TrademarkDTO trademarkDTO) {
        boolean save = trademarkService.save(trademarkDTO);
        return R.success(save);
    }

    // 修改trademark
    @PutMapping("/update")
    public R<Object> update(@RequestBody TrademarkDTO trademarkDTO) {
        boolean save = trademarkService.update(trademarkDTO);
        return R.success(save);
    }

    // 修改trademark
    @DeleteMapping("/remove/{id}")
    public R<Object> update(@PathVariable("id") Integer id) {
        boolean delete = trademarkService.delete(id);
        return R.success(delete);
    }
}
